/**
 * 1装饰器模式，有时候会优于继承
 * 
 * 
 */

 class Coffee{
     make(water){
         return `${water}+咖啡`
     }
     const(){
         return 10
     }

 }
// 加奶的咖啡
class MilkCoffee{
    constructor(parent){
        this.parent = parent;

    }
    make(water){
        return `${this.parent.make(water)}+奶`
    }
    const(){
        return this.parent.const()+2
    }
}
// 加糖的咖啡
class Sugarcoffee{
    constructor(parent){
        this.parent = parent;
    }
    make(water){
        return `${this.parent.make(water)}+糖`
    }
    const(){
        return this.parent.const()+5
    }
}
let coffee = new Coffee();
let mikcoffet = new MilkCoffee(coffee);
let sugarcoffee = new Sugarcoffee(coffee);
//console.log(mikcoffet.make("水"));
console.log(sugarcoffee.make("水"),sugarcoffee.const())


